package com.adopapa.ethexplorer.service;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.Map;

import org.web3j.protocol.core.methods.response.EthBlock.Block;

public class Converter {
	
	
	public static Map<String, Object> toMap(Block block) {
		Map<String, Object> result = new LinkedHashMap<String, Object>();
		
		result.put("number", block.getNumber());
		result.put("hash", block.getHash());
		result.put("parentHash", block.getParentHash());
		result.put("logsBloom", block.getLogsBloom());
		result.put("transactionsRoot", block.getTransactionsRoot());
		result.put("stateRoot", block.getStateRoot());
		result.put("receiptsRoot", block.getReceiptsRoot());
		result.put("author", block.getAuthor());
		result.put("miner", block.getMiner());
		result.put("mixHash", block.getMixHash());
		result.put("difficulty", block.getDifficulty());
		result.put("totalDifficulty", block.getTotalDifficulty());
		result.put("extraData", block.getExtraData());
		result.put("size", block.getSize());
		result.put("gasLimit", block.getGasLimit());
		result.put("gasUsed", block.getGasUsed());
		result.put("timestamp", block.getTimestamp());
		
		
		return result;
	}
	
	public static void main(String[] args) {
		LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(1644576728L, 0, ZoneOffset.UTC);
		System.out.println(localDateTime);
	}

}
